package simple.cashflow.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="t_pegawai")
public class Pegawai implements Serializable {
	
	@Id
	@Column(name="nip")
	private String nip;
	
	@Column(name="nama")
	private String nama;
	
	@Column(name="status")
	private String status;
	
	@Column(name="jumlah_anak")
	private Integer jumlahAnak;
	
	@ManyToOne
	@JoinColumn(name="golongan")
	private Golongan golongan;
	
	@ManyToOne
	@JoinColumn(name="jabatan")
	private Jabatan jabatan;
	
	@Column(name="list_printout")
	private List<Printout> listPrintout = new ArrayList<Printout>();
	
	public Pegawai(){
		
	}
	
	public Pegawai(String nip, String nama, String status, Integer jumAn, Golongan gol, Jabatan jab){
		this.nip = nip;
		this.nama = nama;
		this.status = status;
		this.jumlahAnak = jumAn;
		this.golongan = gol;
		this.jabatan = jab;
	}
	
	public List<Printout> getListPrintout() {
		return listPrintout;
	}
	public void setListPrintout(List<Printout> listPrintout) {
		this.listPrintout = listPrintout;
	}

	public String getNip() {
		return nip;
	}
	public void setNip(String nip) {
		this.nip = nip;
	}
	
	public String getNama() {
		return nama;
	}
	public void setNama(String nama) {
		this.nama = nama;
	}
	
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	public Integer getJumlahAnak() {
		return jumlahAnak;
	}
	public void setJumlahAnak(Integer jumlahAnak) {
		this.jumlahAnak = jumlahAnak;
	}
	
	public Golongan getGolongan() {
		return golongan;
	}
	public void setGolongan(Golongan golongan) {
		this.golongan = golongan;
	}
	
	public Jabatan getJabatan() {
		return jabatan;
	}
	public void setJabatan(Jabatan jabatan) {
		this.jabatan = jabatan;
	}
	
	@Override
	public String toString() {
		return "Pegawai [nip=" + nip + ", nama=" + nama + ", status=" + status
				+ ", jumlahAnak=" + jumlahAnak + ", golongan=" + golongan
				+ ", jabatan=" + jabatan + "]";
	}
	
	public void tambahPrintout(Printout print){
		print.setPegawai(this);
		getListPrintout().add(print);
	}
	
	
}
